package com.zhuss.want.want;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.want.want.CreateWantBo;
import com.zhuss.bean.bo.want.want.DeleteWantBo;
import com.zhuss.bean.bo.want.want.UpdateWantBo;
import com.zhuss.bean.bo.want.want.wechat.CollectWantBo;
import com.zhuss.bean.bo.want.want.wechat.DelTopicWantBo;
import com.zhuss.bean.bo.want.want.wechat.ForwardWantBo;
import com.zhuss.bean.bo.want.want.wechat.ThumbWantBo;
import com.zhuss.bean.bo.want.want.wechat.TopicWantBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * want操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("wantOperateService")
public class WantOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("wantCreate")
	private Processor<Object, CreateWantBo> wantCreate;
	
	@Autowired
	@Qualifier("wantUpdate")
	private Processor<Object, UpdateWantBo> wantUpdate;
	
	@Autowired
	@Qualifier("wantDelete")
	private Processor<Object, DeleteWantBo> wantDelete;
	
	@Autowired
	@Qualifier("wantThumb")
	private Processor<Object, ThumbWantBo> wantThumb;
	
	@Autowired
	@Qualifier("wantCollect")
	private Processor<Object, CollectWantBo> wantCollect;
	
	@Autowired
	@Qualifier("wantForward")
	private Processor<Object, ForwardWantBo> wantForward;
	
	@Autowired
	@Qualifier("wantTopic")
	private Processor<Object, TopicWantBo> wantTopic;
	
	@Autowired
	@Qualifier("wantDelThumb")
	private Processor<Object, ThumbWantBo> wantDelThumb;
	
	@Autowired
	@Qualifier("wantDelCollect")
	private Processor<Object, CollectWantBo> wantDelCollect;
	
	@Autowired
	@Qualifier("wantDelForward")
	private Processor<Object, ForwardWantBo> wantDelForward;
	
	@Autowired
	@Qualifier("wantDelTopic")
	private Processor<Object, DelTopicWantBo> wantDelTopic;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateWantBo bo = (CreateWantBo) param;
		
		wantCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateWantBo bo = (UpdateWantBo) param;
		
		wantUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteWantBo bo = (DeleteWantBo) param;
		
		wantDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbWantBo bo = (ThumbWantBo) param;
		
		wantThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectWantBo bo = (CollectWantBo) param;
		
		wantCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardWantBo bo = (ForwardWantBo) param;
		
		wantForward.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicWantBo bo = (TopicWantBo) param;
		
		wantTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbWantBo bo = (ThumbWantBo) param;
		
		wantDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectWantBo bo = (CollectWantBo) param;
		
		wantDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardWantBo bo = (ForwardWantBo) param;
		
		wantDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicWantBo bo = (DelTopicWantBo) param;
		
		wantDelTopic.process(bo);
		
		return null;
	}
	
}

